#include <bits/stdc++.h>

#define int long long

using namespace std;

void solve()
{
    int n;
    cin >> n;
    int cnt = 9;
    int cz = 1;
    while(1)
    {
        if(n > cnt * cz) n -= cnt * cz;
        else break;
        cnt *= 10;
        cz ++;
    }
    int sum = 0;
    int ns = 9;
    int st = 10;
    int endd = 99;
    for(int i = 1; i <= cz - 1; i ++)
    {
        sum += (ns) * (st + endd) / 2;
        ns *= 10;
        st *= 10;
        endd = endd * 10 + 9; 
    }
    int sub = n / cz;
    if(sub > 0)
    sum += (st + st + sub - 1) * sub / 2;
    n -= n / cz;
    int tp = st + sub;

    
}
signed main()
{
    int t;
    cin >> t;
    while(t --)
    {
        solve();
    }
}